<?
include('config.php');
$iCat   = getValue('iCat');
$page   = getvalue('iPage','int','GET',1);
include('../includes/inc_news_cat_init.php');
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="vi" lang="vi" xmlns:og="http://ogp.me/ns#" xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<title><?=($page > 1)?'Tin Tức '.GetNamecat($iCat).' | Trang '.$page:'Tin Tức '.GetNamecat($iCat)?></title>
<meta name="language" content="vietnamese" />
<meta name="revisit-after" content="1 days" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="AUTHOR" content="Vnupdate" />
<meta name="description" content="Tin cập nhật, tin tức mới nhất, tin tức online về chủ đề <?=GetNamecat($iCat)?>"/>
<meta name="COPYRIGHT" content="Copyright (C) 2012 VnUpdate.net" />
<meta name="ROBOTS" content="INDEX, FOLLOW" />
<meta name="RATING" content="GENERAL" />
<?/*    Facebook content    */ ?>
<meta property="og:title" content="Tin Tức <?=GetNamecat($iCat)?>" />
<meta property="og:type" content="article" />
<meta property="og:url" content="<?=DOMAIN.$_SERVER['REQUEST_URI']?>" />
<meta property="og:image" content="<?=DOMAIN?>/themes/img/logo.png" />
<meta property="og:site_name" content="VnUpdate" />
<meta property="og:description" content="Tin cập nhật, tin tức mới nhất, tin tức online về chủ đề <?=GetNamecat($iCat)?>" />
<meta property="fb:admins" content="100004609203263" />
<meta property="fb:app_id" content="447585838689244"/>
<link href="<?=DOMAIN?>/favicon.png" type="image/x-icon" rel="shortcut icon"/>
<link rel="canonical" href="<?=DOMAIN.$_SERVER['REQUEST_URI']?>" />
<?=$css_global?>
<?//$js_global?>
</head>
<body>
<!-- BEGIN wrapper -->
<div id="wrapper">
  <!-- BEGIN header -->
  <div id="header">
    <!-- begin pages -->
    <!-- begin logo -->
     <div class="logo">
        <a href="/"><img src="http://vnupdate.net/themes/img/logo.png" alt="Logo vnupdate.net"/></a>
    </div>
    <!-- end logo -->
    <!-- begin categories -->
    <div class="categories_nav">
        <ul class="categories">
            <li class="active">
                <a href="/" title="Tin tức cập nhật vnupdate.net - Tin tức online 24h">Home</a>
            </li>  
            <li class="">
                <a href="/xa-hoi.htm" title="Xã hội">Xã hội</a>
            </li> 
            <li class="">
                <a href="/the-gioi.htm" title="Thế giới">Thế giới</a>
            </li> 
            <li class="">
                <a href="/kinh-te.htm" title="Kinh tế">Kinh tế</a>
            </li> 
            <li class="">
                <a href="/phap-luat.htm" title="Pháp luật">Pháp luật</a>
            </li>
            <li class="">
                <a href="/bong-da.htm" title="Bóng đá">Bóng đá</a>
            </li>
            <li class="">
                <a href="/tinh-yeu-gioi-tinh.htm" title="Tình yêu - Giới tính">Tình yêu - Giới tính</a>
            </li>
            <li class="">
                <a href="/gioi-tre.htm" title="Giới trẻ">Giới trẻ</a>
            </li>
            <li class="">
                <a href="/van-hoa.htm" title="Văn hóa">Văn hóa</a>
            </li>
            <li class="">
                <a href="/giai-tri.htm" title="Giải trí">Giải trí</a>
            </li>
            
            <li class="">
                <a href="/cong-nghe.htm" title="Công nghệ">Công nghệ số</a>
            </li>
            <li class="">
                <a href="/giao-duc.htm" title="Giáo dục">Giáo dục</a>
            </li>
            <li class="">
                <a href="/khoa-hoc.htm" title="Khoa học">Khoa học</a>
            </li>
            <li class="">
                <a href="/chuyen-la.htm" title="Chuyen la">Chuyện lạ</a>
            </li>
        </ul>
    </div>
    <!-- end categories -->
  </div>
  <!-- END header -->
  <!-- BEGIN content -->
  <div id="content">
    <!-- begin featured -->
    <div id="featured">
        <? foreach($list_news as $view){?>
        <div class="post">
            <h2><a href="<?=DOMAIN.generate_detail_url($view,GetNamecat($view['new_cat_id']))?>"><?=$view['new_title']?></a></h2>
            <p class="details" itemprop="datePublished"><time  datetime="<?=date('d/m/y ',$view['new_date'])?> <?=date('H:i',$view['new_date'])?>"> <?=getDateTime('','1','1','1','',$view['new_date']+5*3600)?></time></p>
            <div class="thumb"><a href="<?=DOMAIN.generate_detail_url($view,GetNamecat($view['new_cat_id']))?>"><img src="<?=$view['new_picture']?>" alt="<?=$view['new_title']?>" /></a></div>
            <p class="sumary"><?=(!empty($view['new_teaser']))?$view['new_teaser']:strip_tags(cut_string($view['new_detail'],250,'.'))?></p>
            <p class="readmore">[ <a href="<?=DOMAIN.generate_detail_url($view,GetNamecat($view['new_cat_id']))?>">read more</a> ]</p>
            <p class="tags">TAGS:<?$arr_tags = explode(',',$view['new_tags']);
                $total_tags = count($arr_tags);
                foreach($arr_tags as $key=>$tags){
                    $tags = trim($tags);
                    if(!empty($tags)){
                        $tags_link  =   trim(str_replace(' ','+',$tags));
                        if($key <= $total_tags - 3){
                        ?><a href="<?=DOMAIN.'/tags/'.$tags_link?>"><?=trim($tags)?></a>, <? 
                        }else{
                        ?><a href="<?=DOMAIN.'/tags/'.$tags_link?>"><?=trim($tags)?></a><?
                        }   
                    }
                }
                ?> </p>
            <div class="break"></div>
        </div>
        <?}?>
    <!-- end featured -->
    <!-- begin padding -->
    <div class="paging">
    <?
        $num_page = round($total_record['total']/24);
        if($num_page <= 9){
            for($i=1;$i<=10;$i++){
                echo $i;
                ?>
                <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$i?>.htm"><?=$i?></a>
                <?
            }   
        }else{
            if($page >= 5){
                for($i=$page-4;$i<=$page;$i++){
                    if($i == $page){
                    ?>
                    <a class="current" href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$i?>.htm"><?=$i?></a>
                    <? 
                    }else{
                        ?>
                        <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$i?>.htm"><?=$i?></a>
                        <?
                    }
                } 
                for($i=$page+1;$i<=$page+4;$i++){
                    ?>
                    <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$i?>.htm"><?=$i?></a>
                    <?
                } 
            }else if($page == 1){
                for($i=$page;$i<=$page+8;$i++){
                    if($i == $page){
                    ?>
                    <a class="current" href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$i?>.htm"><?=$i?></a>
                    <? 
                    }else{
                        ?>
                        <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$i?>.htm"><?=$i?></a>
                        <?
                    }
                } 
            }else if($page == 2){
                    ?>
                    <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-1.htm">1</a>
                    <?
                    for($i=$page;$i<=$page+7;$i++){
                        if($i == $page){
                        ?>
                        <a class="current" href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$i?>.htm"><?=$i?></a>
                        <? 
                        }else{
                            ?>
                            <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$i?>.htm"><?=$i?></a>
                            <?
                        }
                    } 
            }else if($page == 3){
                    ?>
                    <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-1.htm">1</a>
                    <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-1.htm">2</a>
                    <?
                    for($i=$page;$i<=$page+6;$i++){
                        if($i == $page){
                        ?>
                        <a class="current" href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$i?>.htm"><?=$i?></a>
                        <? 
                        }else{
                            ?>
                            <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$i?>.htm"><?=$i?></a>
                            <?
                        }
                    } 
            }else if($page == 4){
                    ?>
                    <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-1.htm">1</a>
                    <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-2.htm">2</a>
                    <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-2.htm">3</a>
                    <?
                    for($i=$page;$i<=$page+5;$i++){
                        if($i == $page){
                        ?>
                        <a class="current" href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$i?>.htm"><?=$i?></a>
                        <? 
                        }else{
                            ?>
                            <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$i?>.htm"><?=$i?></a>
                            <?
                        }
                    } 
            }else if($page == $num_page){
                for($i=$page;$i<=$page-5;$i--){
                    if($i == $page){
                    ?>
                    <a class="current" href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$i?>.htm"><?=$i?></a>
                    <? 
                }else{
                    ?>
                    <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$num_page-3?>.htm"><?=$num_page-3?></a>
                    <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$num_page-2?>.htm"><?=$num_page-2?></a>
                    <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$num_page-1?>.htm"><?=$num_page-1?></a>
                    <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$num_page?>.htm"><?=$num_page?></a>
                    <?
                }
                } 
            }else if($page == $num_page - 1){
                for($i=$page;$i<=$page-6;$i--){
                if($i == $page){
                    ?>
                    <a class="current" href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$i?>.htm"><?=$i?></a>
                    <? 
                }else{
                    ?>
                    <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$i?>.htm"><?=$i?></a>
                    <?
                }
                
                ?>
                <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$num_page-2?>.htm"><?=$num_page-2?></a>
                <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$num_page-1?>.htm"><?=$num_page-1?></a>
                <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$num_page?>.htm"><?=$num_page?></a>
                <?
                }
            }else if($page == $num_page - 1){
                for($i=$page;$i<=$page-7;$i--){
                if($i == $page){
                    ?>
                    <a class="current" href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$i?>.htm"><?=$i?></a>
                    <? 
                }else{
                    ?>
                    <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$i?>.htm"><?=$i?></a>
                    <?
                }
                
                ?>
                <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$num_page-1?>.htm"><?=$num_page-1?></a>
                <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$num_page?>.htm"><?=$num_page?></a>
                <?
                }
            }else if($page == $num_page - 1){
                for($i=$page;$i<=$page-8;$i--){
                if($i == $page){
                    ?>
                    <a class="current" href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$i?>.htm"><?=$i?></a>
                    <? 
                }else{
                    ?>
                    <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$i?>.htm"><?=$i?></a>
                    <?
                }
                
                ?>
                <a href="/<?=removeTitle(GetNamecat($iCat))?>/trang-<?=$num_page?>.htm"><?=$num_page?></a>
                <?
                }
            }
            
    }
    ?>
</div>

    <!-- end padding -->
  </div>
  <!-- END content -->
  <!-- BEGIN sidebar -->
  <div id="sidebar">
    <!-- begin sponsors -->
    <!-- END right -->
  </div>
  <!-- END sidebar -->
</div>
</div>
<!-- END wrapper -->
<!-- BEGIN footer -->
<div id="footer">
Copyright &copy; 2013 - <a href="http://vnupdate.com/">Vnupdate</a> &middot; All Rights Reserved
</div>
<!-- END footer -->
</body>
</html>
